package dk.dashboardFP.panels.textPanel {
	import dk.dashboardFP.panels.subPanels.ui.windowSubPanelUI.WindowContentEvent;
	import dk.dashboardFP.panels.ui.text.DFPFonts;
	import dk.dashboardFP.panels.subPanels.ui.windowSubPanelUI.IWindowContent;

	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.text.AntiAliasType;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;

	/**
	 * @author josef
	 */
	public class TextWindowContent extends Sprite implements IWindowContent {
		private var _text : String;
		private var _tf : TextField;
		private var _margin : Number=5;

		public function TextWindowContent() {
			setupElements();
		}

		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// interface
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		
		public function setWindowDimentions(pWindowDimentions : Point) : void {
			_tf.width = pWindowDimentions.x - _margin*2;
		}

		public function set nWindowWidth(nWindowWidth : Number) : void {
			_tf.width = nWindowWidth-_margin*2;
		}

		public function set nWindowHeight(nWindowHeight : Number) : void {
		}
		
		public function get text() : String { 
			return _text; 
		}
		
		public function set text(oNewValue:String) : void { 
			
			_text="<font size='10' color='#ffffff' face='"+DFPFonts.REGULAR + "'>" + oNewValue+"</font>";
			_tf.htmlText = _text;
			
			dispatchEvent(new WindowContentEvent(WindowContentEvent.CONTENT_DIMENTIONS_CHANGE));
		}

		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
		// setup
		//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

		private function setupElements() : void {
			
			// textbox 
			_tf=new TextField();
			addChild(_tf);
			
			_tf.antiAliasType=AntiAliasType.ADVANCED;
			_tf.embedFonts=true;
			
			_tf.multiline=true;
			_tf.wordWrap=true;
			
			_tf.autoSize=TextFieldAutoSize.LEFT;
			
			_tf.border=true;
			
			_tf.x = _margin;
			_tf.y = _margin;
		}
	}
}
